import React,{Component} from 'react'
import Dialog from './dialog'

class Content extends Component{
  constructor(){
    super();
    this.state={
      isShowDialog:false,
      dialogInfo:{
        title:sessionStorage.name||"",
        content:"",
        dialogHanlder:null
      }
    };
  }
  handlerDialog(action){
    if(action=="ok"){
        console.log("点击了确定按钮");
    }else if(action=="close"){
      console.log("点击了取消或者是关闭按钮");
    }
    this.setState({
      isShowDialog:false
    });
  }
  handlerShowDialog(){
    let dialogInfo = {
      title: "弹窗标题",
      content : "您好，想点击确定就点击确定",
      dialogHanlder:this.handlerDialog.bind(this)
    }
    this.setState({
      isShowDialog:true,
      dialogInfo:dialogInfo
    });
  }
  render(){
    return (
        <div>
            <button onClick={this.handlerShowDialog.bind(this)}>显hzhzh示弹窗</button>
            {this.state.isShowDialog ? <Dialog  {...this.state.dialogInfo}/>:null}
        </div>

    )
  }
}
export default Content
